<?php

namespace App\Http\Controllers\Admin;

use App\Models\AdminUser;
use Illuminate\Http\Request;

class AdminUserController extends BaseController
{
    public function __construct()
    {
        parent::__construct();
        $this->middleware('check_admin_login');
    }

    public function info(Request $request)
    {
        $token = $request->header('access-token');
        $adminuser = decrypt($token);

        $adminuser = json_decode($adminuser,true);

        $info = AdminUser::find($adminuser['admin_id']);

        $result = [
            'username'      => $info['username'],
            'last_login_at' => $info['last_login_at'],
        ];
        return $this->ok($result);
    }
}
